﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Index.Master" Inherits="System.Web.Mvc.ViewPage<DAL.SysLog>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        $(function () {
            $("#Message").autocomplete({
                source: "../SysLog/SearchAutoComplete/Message",
                minLength: 1,
                select: function (event, ui) {
                    //  alert(ui.item.value);
                }
            }); $("#Ip").autocomplete({
                source: "../SysLog/SearchAutoComplete/Ip",
                minLength: 1,
                select: function (event, ui) {
                    //  alert(ui.item.value);
                }
            });
            flexiSelect = function (ids, grid) {
                //主键列和显示列之间用 ^ 分割   每一项用 , 分割
                var arr = new Array(0);
                $('.trSelected  td:nth-child(1) div', grid.gDiv).each(function () {
                    //遍历选中行对象，获取值第一列（Id）
                    arr.push($(this).text());
                })
                $('.trSelected  td:nth-child(3) div', grid.gDiv).each(function (i) {
                    //遍历选中行对象，获取值第三列（ Name）
                    if (i == 0) {
                        arr.push("^"); //主键列和显示列的分割符 ^ 
                        i++;
                    }
                    arr.push($(this).text()); //将值插入数组
                })
                if (arr.length < 3) {//少于一条
                    msgShow("操作提示", "请选择数据!", "info");
                    return;
                }
                //                if (arr.length > 3) {//多于一条
                //                    alert("请只选择一条数据!");
                //                    return;
                //                }
                if (arr.length >= 3) {//一条数据和多于一条
                    returnParent(arr.join("&")); //每一项用 & 分割
                }
            }
            flexiQuery = function (ids, grid) {
                $('#divQuery').window({
                    collapsible: false,
                    minimizable: false,
                    maximizable: false,
                    tools: [{
                        iconCls: 'icon-search',
                        handler: function () {
                            var search = "";
                            $('#divQuery').find(":text,:selected,select,textarea,:hidden,:checked,:password").each(function () {
                                search = search + this.id + "&" + this.value + "^";
                            });
                            grid.doSearch(search); //执行查询
                            $("#flexigridData2").flexReload(); //刷新
                            $('#divQuery').window('close');
                        }
                    }]
                });
                $('#divQuery').window('open');
            };

            flexiOut = function (ids, grid) {
                var queryJDiv = $(".divQuery:last"); //选择div中的数据

                var search = "";
                queryJDiv.find(":text,:selected,textarea,:hidden,:checked,:password").each(function () {
                    search = search + this.id + "&" + this.value + "^";

                });

                grid.doDaoChu("../SysLog/GetDaoChu");
            };
            flexiView = function (ids, grid) {
                var arr = new Array(0);
                $('.trSelected  td:nth-child(1) div', grid.gDiv).each(function (i) {
                    //遍历选中行对象，获取值第一列（id）
                    arr.push($(this).text());
                })
                if (arr.length == 0) {
                    msgShow("操作提示", "请选择数据!", "info");
                    return;
                }
                if (arr.length > 1) {
                    msgShow("操作提示", "请只选择一条需要查看的数据!", "info");
                    return;
                }
                if (arr.length == 1) {
                    var parent = window.dialogArguments; //获取父页面
                    if (parent != null && parent != "undefined") {//如果是父页面就不许操作
                        msgShow("操作提示", "请不要在弹出框中新建，可以转到列表中查看！", "info");
                        return;
                    }
                    window.location.href = "../SysLog/Details/" + arr[0];
                    return;
                }
            }
            function flexiCreate() {
                var parent = window.dialogArguments; //获取父页面
                if (parent != null && parent != "undefined") {//如果是父页面就不许操作
                    msgShow("操作提示", "请不要在弹出框中新建，可以转到列表中新建！", "info");
                    return;
                }
                window.location.href = "../SysLog/Create/" + $("#hidtreeid").val();
                return;
            }
            flexiModify = function (ids, grid) {
                var parent = window.dialogArguments; //获取父页面
                if (parent != null && parent != "undefined") {//如果是父页面就不许操作
                    msgShow("操作提示", "请不要在弹出框中修改，可以转到列表中修改！", "info");
                    return;
                }
                var arr = new Array(0);
                $('.trSelected  td:nth-child(1) div', grid.gDiv).each(function (i) {
                    //遍历选中行对象，获取值第一列（id）
                    arr.push($(this).text());
                })
                if (arr.length == 0) {
                    msgShow("操作提示", "请选择数据!", "info");
                    return;
                }
                if (arr.length > 1) {
                    msgShow("操作提示", "请只选择一条需要查看的数据!", "info");
                    return;
                }
                if (arr.length == 1) {
                    window.location.href = "../SysLog/Edit/" + arr[0];
                    return;
                }
            };

            flexiDelete = function (ids, grid) {
                var parent = window.dialogArguments; //获取父页面
                if (parent != null && parent != "undefined") {//如果是父页面就不许操作
                    msgShow("请不要在弹出框中删除，可以转到列表中删除！", "info");
                    return;
                }
                var arr = new Array(0);
                $('.trSelected  td:nth-child(1) div', grid.gDiv).each(function (i) {
                    //主要的一列，遍历选中行对象，获取值第一列（id）
                    arr.push($(this).text());
                })
                if (arr.length == 0) {
                    msgShow("操作提示", "请选择数据!", "info");
                    return;
                }
                $.messager.confirm('删除提示', '确认删除这' + arr.length + '项吗?', function (r) {
                    if (r) {
                        $.post("../SysLog/Delete", { query: arr.join(",") }, function (res) {
                            if (res == "OK") {
                                $("#flexigridDataSef").flexReload();
                                msgShow("操作提示", "删除成功!", "info");
                            }
                            else {
                                if (res == "") {
                                    msgShow("操作提示", "删除失败!请查看该数据与其他模块下的信息的关联，或联系管理员。", "info");

                                }
                                else {
                                    msgShow("操作提示", res, "info");

                                }
                            }
                        });
                    }
                    else
                        return;
                });
            };


            $("#flexigridData").flexigrid(
			{
			    url: '../SysLog/FlexigridList',
			    colModel: [
				   { display: '<%: Html.LabelFor(model => model.Id) %>', name: 'Id', width: 205, hide: true, sortable: false, align: 'left' }
					, { display: '序号', name: 'MySeq', width: 26, sortable: false, align: 'left' }
					, { display: '<%: Html.LabelFor(model => model.LeiXing) %>', name: 'LeiXing', width: 76, sortable: true, align: 'left' }
					, { display: '<%: Html.LabelFor(model => model.PersonId) %>', name: 'PersonId', width: 76, sortable: true, align: 'left' }
					, { display: '<%: Html.LabelFor(model => model.Message) %>', name: 'Message', width: 76, sortable: true, align: 'left' }
					, { display: '<%: Html.LabelFor(model => model.Result) %>', name: 'Result', width: 76, sortable: true, align: 'left' }
					, { display: '<%: Html.LabelFor(model => model.MenuId) %>', name: 'MenuId', width: 76, sortable: true, align: 'left' }
					, { display: '<%: Html.LabelFor(model => model.Ip) %>', name: 'Ip', width: 76, sortable: true, align: 'left' }

                   	],
			    buttons: [
                    { name: '查询', bclass: 'searchcss', onpress: flexiQuery },
                    { separator: true },
                    { name: '详细', bclass: 'detailcss', onpress: flexiView },
                    { separator: true },
                    { name: '创建', bclass: 'addcss', onpress: flexiCreate },
                    { separator: true },
				    { name: '删除', bclass: 'deletecss', onpress: flexiDelete },
                    { separator: true },
                    { name: '修改', bclass: 'editcss', onpress: flexiModify },
				    { separator: true },
                    { name: '选择', bclass: 'selectcss', onpress: flexiSelect }
			    //				    ,{ separator: true },
			    //                    { name: '导出', bclass: 'excelcss', onpress: flexiOut }

				],
			    sortname: "CreateTime",
			    sortorder: "asc",
			    usepager: true,
			    useRp: true,
			    showTableToggleBtn: true,
			    height: 300

			});
            var parent = window.dialogArguments; //获取父页面
            if (parent == "undefined" || parent == null) {
                $(".fbutton:last").hide();
            } else {
                $(".fbutton").hide();
                $(".fbutton:first").show();
                $(".fbutton:last").show();
            }
            using('window', function () { });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table id="flexigridData">
    </table>
    <div id="divQuery" title="查询列表" class="easyui-window" closed="true" modal="false"
        style="padding: 5px; background: #fafafa;">
        
            <div class="input">
                <div class="editor-label">
                    <%: Html.LabelFor(model => model.LeiXing) %>
                </div>
                <div class="editor-field">
                    <%=Html.DropDownListFor(model => model.LeiXing,App.Models.SysFieldsDDL.GetSysFields("SysLog","LeiXing"),"请选择")%>  
                </div>
            </div>
            <br style="clear:both;" /> 
            <div class="input">
                <div class="editor-label">
                    <%: Html.LabelFor(model => model.Message) %>
                </div>
                <div class="editor-field">
                    <%: Html.EditorFor(model => model.Message) %>
                </div>
            </div>
            <br style="clear:both;" /> 
            <div class="input">
                <div class="editor-label">
                    <%: Html.LabelFor(model => model.Ip) %>
                </div>
                <div class="editor-field">
                    <%: Html.EditorFor(model => model.Ip) %>
                </div>
            </div>
            <br style="clear:both;" />
    </div>
    <div id="dialo" title="操作">
    </div>
</asp:Content>
